package com.dji.sample.wayline.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dji.sample.wayline.model.entity.WaylineFileEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.test.context.jdbc.Sql;

/**
 * @author sean
 * @version 0.3
 * @date 2021/12/22
 */
public interface IWaylineFileMapper extends BaseMapper<WaylineFileEntity> {

    @Select({"<script>",
            "select a.*,b.status,b.type from wayline_file a left join wayline_info b on a.uni_key=b.uni_Key where 1=1 ",
            "<when test='orgCode!=null' >",
            "AND a.org_code like '${orgCode}%'",
            "</when>",
            "<when test='deviceNo!=null' >",
            "AND a.device_no = #{deviceNo}",
            "</when>",
            "<when test='status!=null' >",
            "AND b.status = #{status}",
            "</when>",
            "<when test='type!=null' >",
            "AND b.type = #{type}",
            "</when>",
            "<when test='name!=null' >",
            "AND a.name like '%${name}%'",
            "</when>",
            "order by a.id desc",
            "</script>"})
    Page<WaylineFileEntity> page(@Param(value = "orgCode") String orgCode, @Param(value = "deviceNo") String deviceNo, @Param(value = "status") Integer status, @Param(value = "name") String name,@Param(value = "type") Integer type,Page<WaylineFileEntity> page);
}
